using System;
using System.Collections.Generic;
using DevExpress.CodeRush.Core;
using DevExpress.CodeRush.StructuralParser;
using CR.StyleCop;
using CR.StyleCop.Utils;

namespace CR.StyleCop {
    public abstract class BaseStyleCopIssueSearcher<T1, T2> : BaseCodeIssueSearcher {

        public override void CheckCodeIssues(CheckCodeIssuesEventArgs ea) {
            if (ea.Scope == null)
                return;

            var firstIssues = FindFirstIssues(SourceUtils.GetElementEnumerator<T1, T2>(ea.Scope));
            foreach (var item in firstIssues) {
                SourceUtils.AddIssue(ea, item);
            }
        }

        public abstract IEnumerable<StyleCopIssue> FindFirstIssues(IEnumerable<IElement> elements);
    }
}
